`timescale 1ns / 1ns

module crydap_tb;

wire [127:0] outtxt;
reg clk,wrsben,wrregen,mixsel,reginsel;
reg [1:0] keyadsel;
reg [3:0] wrsbaddr;
reg [127:0] sbdata,intxt,roundkey;

enciphe  enciphe1(clk,wrsben,wrsbaddr,sbdata,keyadsel,mixsel,reginsel,wrregen,intxt,roundkey,outtxt);


//clock generation				   
initial clk = 1;
always #50 clk = ~clk;

initial 
	begin 
		
		//encryption sbox configuration.
		#100 wrsben=1;
		     wrsbaddr=4'd0;
		     sbdata=128'h637c777bf26b6fc53001672bfed7ab76;
		#100 wrsben=1;
		     wrsbaddr=4'd1;
		     sbdata=128'hca82c97dfa5947f0add4a2af9ca472c0;
		#100 wrsben=1;
		     wrsbaddr=4'd2;
		     sbdata=128'hb7fd9326363ff7cc34a5e5f171d83115;
		#100 wrsben=1;
		     wrsbaddr=4'd3;
		     sbdata=128'h04c723c31896059a071280e2eb27b275;
		#100 wrsben=1;
		     wrsbaddr=4'd4;
		     sbdata=128'h09832c1a1b6e5aa0523bd6b329e32f84;
		#100 wrsben=1;
		     wrsbaddr=4'd5;
		     sbdata=128'h53d100ed20fcb15b6acbbe394a4c58cf;
		#100 wrsben=1;
		     wrsbaddr=4'd6;
		     sbdata=128'hd0efaafb434d338545f9027f503c9fa8;
		#100 wrsben=1;
		     wrsbaddr=4'd7;
		     sbdata=128'h51a3408f929d38f5bcb6da2110fff3d2;
		#100 wrsben=1;
		     wrsbaddr=4'd8;
		     sbdata=128'hcd0c13ec5f974417c4a77e3d645d1973;
		#100 wrsben=1;
		     wrsbaddr=4'd9;
		     sbdata=128'h60814fdc222a908846eeb814de5e0bdb;
		#100 wrsben=1;
		     wrsbaddr=4'd10;
		     sbdata=128'he0323a0a4906245cc2d3ac629195e479;
		#100 wrsben=1;
		     wrsbaddr=4'd11;
		     sbdata=128'he7c8376d8dd54ea96c56f4ea657aae08;
		#100 wrsben=1;
		     wrsbaddr=4'd12;
		     sbdata=128'hba78252e1ca6b4c6e8dd741f4bbd8b8a;
		#100 wrsben=1;
		     wrsbaddr=4'd13;
		     sbdata=128'h703eb5664803f60e613557b986c11d9e;
		#100 wrsben=1;
		     wrsbaddr=4'd14;
		     sbdata=128'he1f8981169d98e949b1e87e9ce5528df;
		#100 wrsben=1;
		     wrsbaddr=4'd15;
		     sbdata=128'h8ca1890dbfe6426841992d0fb054bb16;
		#100 wrsben=0;
		     
		
		//encryption.
		#100 	
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=0;
		     reginsel=0;
		     intxt=128'h3243f6a8_885a308d_313198a2_e0370734;
		     roundkey=128'h2b7e1516_28aed2a6_abf71588_09cf4f3c;
		                          
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'ha0fafe17_88542cb1_23a33939_2a6c7605;		                
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'hf2c295f2_7a96b943_5935807a_7359f67f;		                
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'h3d80477d_4716fe3e_1e237e44_6d7a883b;           
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'hef44a541_a8525b7f_b671253b_db0bad00;                      
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'hd4d1c6f8_7c839d87_caf2b8bc_11f915bc;      
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'h6d88a37a_110b3efd_dbf98641_ca0093fd;
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'h4e54f70e_5f5fc9f3_84a64fb2_4ea6dc4f;
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'head27321_b58dbad2_312bf560_7f8d292f;
      #100 
		     wrregen=1;
		     keyadsel=2'b01;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'hac7766f3_19fadc21_28d12941_575c006e;
      #100 
		     wrregen=1;
		     keyadsel=2'b10;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'hd014f9a8_c9ee2589_e13f0cc8_b6630ca6;
		                
      #100 wrregen=0;		

		//decryption sbox configuration.
		#20  wrsben=1;
		     wrsbaddr=4'd0;
		     sbdata=128'h52096ad53036a538bf40a39e81f3d7fb;
		#100 wrsben=1;
		     wrsbaddr=4'd1;
		     sbdata=128'h7ce339829b2fff87348e4344c4dee9cb;
		#100 wrsben=1;
		     wrsbaddr=4'd2;
		     sbdata=128'h547b9432a6c2233dee4c950b42fac34e;
		#100 wrsben=1;
		     wrsbaddr=4'd3;
		     sbdata=128'h082ea16628d924b2765ba2496d8bd125;
		#100 wrsben=1;
		     wrsbaddr=4'd4;
		     sbdata=128'h72f8f66486689816d4a45ccc5d65b692;
		#100 wrsben=1;
		     wrsbaddr=4'd5;
		     sbdata=128'h6c704850fdedb9da5e154657a78d9d84;
		#100 wrsben=1;
		     wrsbaddr=4'd6;
		     sbdata=128'h90d8ab008cbcd30af7e45805b8b34506;
		#100 wrsben=1;
		     wrsbaddr=4'd7;
		     sbdata=128'hd02c1e8fca3f0f02c1afbd0301138a6b;
		#100 wrsben=1;
		     wrsbaddr=4'd8;
		     sbdata=128'h3a9111414f67dcea97f2cfcef0b4e673;
		#100 wrsben=1;
		     wrsbaddr=4'd9;
		     sbdata=128'h96ac7422e7ad3585e2f937e81c75df6e;
		#100 wrsben=1;
		     wrsbaddr=4'd10;
		     sbdata=128'h47f11a711d29c5896fb7620eaa18be1b;
		#100 wrsben=1;
		     wrsbaddr=4'd11;
		     sbdata=128'hfc563e4bc6d279209adbc0fe78cd5af4;
		#100 wrsben=1;
		     wrsbaddr=4'd12;
		     sbdata=128'h1fdda8338807c731b11210592780ec5f;
		#100 wrsben=1;
		     wrsbaddr=4'd13;
		     sbdata=128'h60517fa919b54a0d2de57a9f93c99cef;
		#100 wrsben=1;
		     wrsbaddr=4'd14;
		     sbdata=128'ha0e03b4dae2af5b0c8ebbb3c83539961;
		#100 wrsben=1;
		     wrsbaddr=4'd15;
		     sbdata=128'h172b047eba77d626e169146355210c7d;
		#100 wrsben=0;
		     
		
		//decryption.
		#100 	
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=0;
		     reginsel=0;
		     intxt=128'h3925841d_02dc09fb_dc118597_196a0b32;
		     roundkey=128'hd014f9a8_c9ee2589_e13f0cc8_b6630ca6;	
		                      
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'hac7766f3_19fadc21_28d12941_575c006e;
		     		                
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'head27321_b58dbad2_312bf560_7f8d292f;
		     		                
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'h4e54f70e_5f5fc9f3_84a64fb2_4ea6dc4f;
		                
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'h6d88a37a_110b3efd_dbf98641_ca0093fd;
		                           
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;		     
		     roundkey=128'hd4d1c6f8_7c839d87_caf2b8bc_11f915bc;      
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'hef44a541_a8525b7f_b671253b_db0bad00;
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'h3d80477d_4716fe3e_1e237e44_6d7a883b;
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'hf2c295f2_7a96b943_5935807a_7359f67f;
      #100 
		     wrregen=1;
		     keyadsel=2'b00;
		     mixsel=1;
		     reginsel=1;
		     roundkey=128'ha0fafe17_88542cb1_23a33939_2a6c7605;
      #100 
		     wrregen=1;
		     keyadsel=2'b11;
		     mixsel=0;
		     reginsel=0;
		     roundkey=128'h2b7e1516_28aed2a6_abf71588_09cf4f3c;
		                
      #100 wrregen=0;	
      
      			     		      
        		
		#200 $stop;		
	end
					
endmodule